"""
指数分布

"""

import numpy as np
from scipy.stats import expon as E
import matplotlib.pyplot as plt
import random
import math


def exp(lam):
    p = random.random()
    # 返回x
    return -math.log(1 - p) / lam


x2 = []
for i in range(100):
    x2.append(exp(1))

x2 = sorted(x2)  # 排序
print(x2)
y2 = np.linspace(0, 1, 100)
print(y2)
plt.plot(x2, y2, color='red')

rv1 = E(scale=1)
x = np.linspace(0, 5, 100)
# 分布函数
plt.plot(x, rv1.cdf(x), color='green')

plt.show()
